// 创建constructor function
function User(name, interests) {
    this.name = name;
    this.interests = interests;
    this.greeting = function() {
        console.log('Hi, I\'m ' + this.name + ".");
    }
}

//使用new调用这个构造函数来创建一个user对象
var user = new User('Sunny', ['Traveling', 'Swimming']);
user.greeting();    // Hi, I'm Sunny.

//甚至可以用new后面不带参数(很不推荐使用)
//当然 结果是undefined
var user1 = new User;
user1.greeting();         // Hi, I'm undefined. 
console.log(user1.name)   //undefined
